 function xDraw=matricvariateNDraw(x,muMat,QChol,PChol)
% 
%  matricvariateNDraw(x,muMat,QChol,PChol)
% 
% Generates a draw from the matricvariate Normal MN(muMat,Q kron P) 
% *Note* 
%  QChol=chol(Q)  such that Q=Qchol'*Qchol
%  PChol=chol(P)  such that P=Pchol'*Pchol
%
%% Input 
% x:     [p,q] matrix
% muMat: [p,q] matrix with Mean 
% QChol: [q,q] matrix with INV(Q) 
% PChol: [p,p] matrix with INV(P)
% 
%% Output 
% xDraw  [p,q]: matrix with a draw 
% Alejandro Justiniano August 30 2013 (C) 
% =========================================================================
[Nr,Nc]=size(x); 
Z=randn(Nr,Nc); 
xDraw=PChol'*Z*QChol+muMat; 

 end 